package app

import (
	"github.com/gin-gonic/gin"
	"github.com/redis/go-redis/v9"
	"gorm.io/gorm"
	"xs.jsjb/internal/app/menu"
	"xs.jsjb/internal/app/user"
	"xs.jsjb/pkg/servers"
)

var Entities = []interface{}{user.Entity, menu.Entity}

func Build(db *gorm.DB, rdb *redis.Client) *gin.Engine {
	//数据表迁移,用一次之后记得注释
	//if err := db.AutoMigrate(Entities...); err != nil {
	//	zap.L().Error("auto migrate  tables error", zap.Error(err))
	//}

	return servers.NewHttpServer(
		user.Build(db),
		menu.Build(db),
	)
}
